<template lang="">
		<view class="home">
			<view class="input"  v-if="type == 1 ? true : false">
				<view class="text" @click="show=true" v-if="!showListData.length">
					<text>请选择便签</text>
					<u-icon name="arrow-down-fill" style="color: #C0C0C0;font-size: 20rpx;"></u-icon>
				</view>
				<view class="showList"  v-if="showListData.length">
					<u-icon name="close-circle" @click="clearShowListData"  class="icon" style="color: #C0C0C0;font-size: 35rpx;">关闭</u-icon>
					<view class="showListArr" @click="show=true" >
						<view class="showListItem"  v-for="(item,index) in showListData" :key="index">
							{{item}}
						</view>
					</view>
					
				</view>
				
				
			</view>
			
			<view class="noInput" @click="show=true" v-if="type == 2 ? true : false">
				<view class="showList"  v-if="showListData.length">
					<view class="showListItem" v-for="(item,index) in showListData" :key="index">
						{{item}}
					</view>
				</view>
				
				
			</view>
			
			<u-modal v-model="show"  width="95%" :show-title="false" :title-style="{color: 'black'}" :show-cancel-button="false" :show-confirm-button="false">
							<view class="slot-content formContent">
								<view class="title">
									选择标签
									<u-icon class="close" @click="show=false" name="close"></u-icon>
								</view>
								<view class="content" >
									<view class="item" v-for="(item,index) in checkBtnArr" :key="item.title">
										<view class="label">
											{{item.title}}:
										</view>
										<view class="checkBtnArr">
											<view class="item"  :class="item.index==index2 ? 'active' : ''" v-for="(item2,index2) in item.checkBtn" :key="index2">
												<text @click="selectItem(index,index2)">{{item2}}</text>
											</view>
										</view>
										
									</view>
								</view>
								<view class="bottomBtn">
									<view class="btn" @click="show=false" >取消</view>
									<view class="btn" @click="submit" type="primary">确认</view>
								</view>
							</view>
				</u-modal>
			
			
		</view>
     
</template>
<script>
	
export default {
    data() {
    	return {
    		showListData:this.inputArr,
			show:false,
			checkBtnArr:[
				{
					title:'客户身份',
					index:-1,
					checkBtn:[
						'企业老板',
						'管理层',
						'公司员工',
						'自由职业',
					]
				},
				{
					title:'客户状态',
					index:-1,
					checkBtn:[
						'合作过',
						'合作中',
						'合作意向',
						'初步沟通',
					]
				},
				{
					title:'客户等级',
					index:-1,
					checkBtn:[
						'机会',
						'一般',
						'潜在',
						'核心',
						'重要',
					]
				}
			],
    	};
    },
    props:{
    	inputArr :{
			type:Array,
			default:()=>{return []}
		}, 
    	type : {
			type : Number,
			default:()=>{return 1}
		},//1 下拉 ，2 按钮
		index1 : {
			type : Number,
		},
		index2 : {
			type : Number,
		},
		labelArr:{
			type:Array,
		}
    },
	methods:{
		async getLabelArr(){
			let res = await this.myhttp({
				method:'GET',
				url:'api/Label/getList',
			}).then(res=>{
				if(res.data.code==1){
					let arr = res.data.data.tag_group
					this.vuex.dispatch('getPullDownLabel',arr)
					// console.log(this.vuex.state.pullDownLabel);
				}
			})
		},
		clearShowListData(){
			this.showListData=[]
			this.checkBtnArr.forEach((item)=>{
				item.index=-1
			})
		},
		submit(){
			this.showListData = []
			this.checkBtnArr.forEach((item)=>{
				if(item.index>-1){
					this.showListData.push(item.checkBtn[item.index])
				}
			})
			this.show = false
			console.log(this.showListData);
			let changeObj = {
				 arrData: this.showListData,
				 index1: this.index1,
				 index2: this.index2,
			}
			this.$emit('changeShowListData',changeObj)
		},
		selectItem(_index,_index2){
			if(this.checkBtnArr[_index].index == _index2){
				this.checkBtnArr[_index].index = -1
			}else{
				this.checkBtnArr[_index].index = _index2
			}
		},
		initShowListData(){
			this.showListData.forEach((item,index)=>{
				this.checkBtnArr.forEach((item2,index2)=>{
					item2.checkBtn.forEach((item3,index3)=>{
						if(item3==item){
						 item2.index = index3	
						}
					})
				})
			})
			console.log(this.checkBtnArr);
		}
	},
	mounted() {
		if(this.showListData.length){
			// this.showListData.forEach((item,index)=>{
			// 	let sameIndex = this.checkBtnArr[index].checkBtn.findIndex((item2)=>{return item2==item })
			// 	this.checkBtnArr[index].index = sameIndex
			// })
		}
	},
	
}
</script>
<style lang="scss" scoped>
    .home{
		.formContent{
			width: 100%;
			height: 800rpx;
			display: flex;
			flex-direction: column;
			.title{
				display: grid;
				place-items: center;
				width: 100%;
				font-size: 36rpx;
				margin-top: 20rpx;
				position: relative;
				.close{
					position: absolute;
					right: 5%;
				}
			}
		
			.content{
				flex: 1;
				width: 95%;
				margin: auto;
				.item{
					margin: 20rpx 0 0;
					.label{
						color: #888888;
						font-size: 26rpx;
					}
					.checkBtnArr{
						display: flex;
						justify-content: space-evenly;
						.item{
							background-color: #F4F4F4;
							color: #444444;
							font-size: 28rpx;
							border-radius: 4rpx;
							padding: 10rpx 20rpx;
						}
						.active{
							color: #fff;
							background-color: #3F8EF7;
						}
					}
				}
			}
		
			.bottomBtn{
				display: flex;
				justify-content: flex-end;
				align-items: center;
				width: 95%;
				margin-bottom: 40rpx;
				.btn{					
					width: 116rpx;
					height: 54rpx;
					font-size: 26rpx;
					display: grid;
					place-items: center;
					background-color: #fff;
					color: #444444;
					border-radius: 4rpx;
					&:nth-child(2){
						background-color: #2772FE;
						color: #fff;
					}
					&:nth-child(1){
						border: 2rpx solid #E8E8E8;
						margin-right: 18rpx;
					}
				}
			}
		}
		
		
		
		
		.input{
			display: flex;
			height: 66rpx;
			width: 696rpx;
			align-items: center;
			border-radius: 8rpx;
			border: 2rpx solid #D9D9D8;
			background-color: #fff;
			padding: 0 20rpx;
			.text{
				width: 100%;
				color: #888888;
				display: flex;
				text{
					flex: 1;
				}
			}
			.showList{
				display: flex;
				position: relative;
				width: 100%;
				align-items: center;
				.icon{
					position: absolute;
					right: 1%;
				}
				.showListArr{
					width: 90%;
					display: flex;
					.showListItem{
						background-color: #fff;
						padding: 5rpx 10rpx;
						border-radius: 4rpx;
						color: #2772FE;
						border: 1px solid #2772FE;
						font-size: 22rpx;
						margin-right: 20rpx;
						&:nth-child(2){
							color: #FE951E;
							border: 1px solid #FE951E;
						}
						&:nth-child(3){
							color: #28B32A;
							border: 1px solid #28B32A;
						}
					}
				}
				
			}
		}		
	
		.noInput{
			.showList{
				background-color: #fff;
				display: flex;
				position: relative;
				width: 100%;
				align-items: center;
				.icon{
					position: absolute;
					right: 1%;
				}
				.showListItem{
					background-color: #fff;
					padding: 5rpx 10rpx;
					border-radius: 4rpx;
					color: #2772FE;
					border: 1px solid #2772FE;
					font-size: 22rpx;
					margin-right: 20rpx;
					&:nth-child(2){
						color: #FE951E;
						border: 1px solid #FE951E;
					}
					&:nth-child(3){
						color: #28B32A;
						border: 1px solid #28B32A;
					}
				}
			}
		}
	}
</style>